<?php

namespace App\Http\Controllers;

use App\Http\Models\User;
use Illuminate\Http\Request;

class RegisterController extends Controller
{
    //

	public function index (  )
	{

		return view('register.index');
	}

	public function register ( Request $request )
	{

		$this->validate($request ,[
			'name' => 'required|unique:users,name',
			'email' => 'required|unique:users,email|email',
			'password' => 'required| confirmed|max:10|min:6',

		]);

		$name = request('name');
		$email = request('email');
		$password = bcrypt(request('password'));

		$user = User::create(compact('name','email','password'));


		return redirect('/login/index');
	}
}
